import { createApp, defineAsyncComponent } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import '@/assets/styles/rest.scss';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css' // 暗黑模式
import '@/assets/styles/dark.scss'; 
import '@/assets/styles/light.scss';


import 'nprogress/nprogress.css';

import createVersionPolling from '@/utils/checkVersion';

const app = createApp(App);

const modules = import.meta.glob('@/components/**/index.vue');
for (const path in modules) {
	const name = path.replace(/^.*\/components\//, '').split('/')[0];
	const component = defineAsyncComponent(modules[path]);
	if (['BasicTableV2'].includes(name)) continue;
	app.component(name, component);
}

app.use(router);
app.use(store);
app.mount('#app');
console.log(import.meta.env);

import.meta.env.MODE != 'dev' &&
	createVersionPolling({
		onUpdated: () => {
			console.log('有新版本，正在刷新页面');
		},
	});
